<template>
  <div class="container">
    
    <div class="settitle">
      <div class="setimg" @click="$router.back()">
        <img src="../assets/imgs/iconse/左箭头.png" alt="" />
      </div>
      <div class="text"><h2>打招呼语</h2></div>
    </div>

    <div class="account">
      <div class="act">
        <span>打招呼语</span>
        <p>选中的打招呼语将在下次与HR沟通时生效</p>
      </div>
      <van-switch
        v-model="checked"
        class="rit"
        active-color="#f78d73"
        inactive-color="#eee"
        size="26px"
        @click="remaker"
      />
    </div>
    <div class="boxs" v-if="checked">
    <van-checkbox-group v-model="result" :max="1">
      <van-checkbox
        :name="item.id"
        @click="keppon(item.id)"
        v-for="item in lists"
        :key="item.id"
        checked-color="#f78d73"
        >{{ item.name }}
        </van-checkbox>
    </van-checkbox-group>
    </div>
  </div>
</template>

<script>
import { getPreinsJsonData } from "../api/preins.js";
export default {
  data() {
    return {
      checked: false,
      result:["a"],
      lists: null,
    };
  },
  methods: {
    getPreinsFun() {
      getPreinsJsonData().then((data) => {
        this.lists = data.lists;
      });
    },
    remaker(){
      this.result=["a"]
      if(!this.checked){
        localStorage.setItem("checktalk","trues")
      }else{
        localStorage.removeItem("checktalk")
      }
      localStorage.setItem("result","a")
    },
    keppon(id){
      this.result=[id]
      localStorage.setItem("result",id)
      console.log(id);
    }
  },
  created() {
    this.getPreinsFun();
  },
};
</script>

<style lang="scss" scoped>
.settitle {
  height: 60px;
  display: flex;
  align-items: center;
  background-color: #fff;
  box-shadow: 0px 0px 0px 1px rgba($color: #cccc, $alpha: 0.4);
  .setimg {
    height: 18px;
    position: absolute;
    left: 15px;
    img {
      height: 100%;
      display: block;
    }
  }
  .text {
    margin: 0 auto;
  }
}
.account {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fff;
  padding: 10px;
  margin: 20px 0px;
  .act {
    font-size: 16px;
    box-sizing: border-box;
    padding-left: 15px;
    p {
      font-size: 12px;
      margin-top: 5px;
      color: #999;
    }
  }
  .catimg {
    height: 12px;
    margin-right: 30px;
    img {
      height: 12px;
    }
  }
  .rit {
    margin-right: 15px;
  }

    
}  


 .boxs ::v-deep .van-checkbox-group{
        font-size: 14px;
        font-weight: 800;
        margin: 20px;
    }


.van-checkbox-group ::v-deep .van-checkbox{
        margin: 20px 0px;
    }

</style>